package com.superbytecode.cloud.web.swagger;

import org.apache.commons.lang3.StringUtils;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
 * All rights Reserved, Designed By www.super-master.com
 *
 * @ProjectName: beacon-cloud
 * @Package: com.superbytecode.cloud.web.swagger
 * @ClassName: SwaggerShortcutController
 * @Description: []
 * <p> </p>
 * @Author: [Lance Ting]
 * @Date: 2024/10/22 12:02
 * @Version: V1.0
 * @Copyright: 2024 www.super-master.com Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
@Controller
public class SwaggerShortcutController {

    private final Environment environment;

    public SwaggerShortcutController(Environment environment) {
        this.environment = environment;
    }

    @GetMapping
    public void index(HttpServletResponse response) throws IOException {
        String contextPath = environment.getProperty("server.servlet.context-path");
        response.sendRedirect((StringUtils.isNotEmpty(contextPath) ? contextPath : StringUtils.EMPTY).concat("/doc.html"));
    }
}